package com.glela.platform.dao.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.glela.common.beans.AreaCommonBean;
import com.glela.platform.dao.IUserLocatedDao;
import com.glela.common.mapper.AreaInfoMapper;
import com.glela.platform.mapper.UserInfoMapper;
import com.glela.platform.model.UserLocatedInfo;

@Repository
public class UserLocatedDaoImp implements IUserLocatedDao {

	@Autowired
	private UserInfoMapper userInfoMapper;
	
	@Autowired
	private AreaInfoMapper areaInfoMapper;
	
	@Override
	public int updateUserLocated(long userId, String areaCode) {
 		return userInfoMapper.updateUserLocated(userId, areaCode);
	}

	@Override
	public UserLocatedInfo getUserLocatedInfo(long userId) {
 		return userInfoMapper.selectUserLocatedInfo(userId);
	}

	@Override
	public int removeUserLocatedInfo(long userId) {
 		return userInfoMapper.deleteUserLocatedInfo(userId);
	}

	@Override
	public int addUserLocatedRecord(UserLocatedInfo userLocatedInfo) {
 		return userInfoMapper.insertUserLocatedRecord(userLocatedInfo);
	}
	/**插入用户常驻地记录
	 * @param userLocatedInfo
	 * @return
	 */
	@Override
	public int insertUserLocatedInfo(UserLocatedInfo userLocatedInfo){
		return userInfoMapper.insertUserLocatedInfo(userLocatedInfo);
	}

	@Override
	public List<AreaCommonBean> selectAreaByName(String name) {
		name = name+"%";
		return areaInfoMapper.selectAreaByName(name);
	}

	@Override
	public int updateUserLocatedInfo(UserLocatedInfo userLocatedInfo) {
 		return userInfoMapper.updatetUserLocatedInfo(userLocatedInfo);
	}
 }
